﻿@model IEnumerable<vngoodlife.Article>

@{
    ViewBag.Title = "ArticleList";
}
<link href="../../../Content/themes/base/jquery.ui.theme.css" rel="stylesheet" type="text/css" />
<link href="../../../Content/themes/base/jquery.ui.base.css" rel="stylesheet" type="text/css" />
<link href="../../../Content/themes/base/jquery.ui.dialog.css" rel="stylesheet" type="text/css" />
<link href="../../../Content/themes/base/autocomplete.css" rel="stylesheet" type="text/css" />
<div class="onecolumn">
    <div class="header">
	    <span>ArticleList</span>
        <div class="switchbutton">
			<a href="@Url.Action("ArticleCreate", "Article")" class="button">Thêm mới</a>
            </div>
    </div>

    <br class="clear"/>

	<div class="content">
   
    @using (Ajax.BeginForm("AdvanceSearch", "Article",
                        new AjaxOptions
                        {
                            UpdateTargetId = "searchResultDisplay",
                            HttpMethod = "GET",
                            InsertionMode = InsertionMode.Replace,
                            LoadingElementId = "progress_related",
                            LoadingElementDuration = 2000,
                            OnSuccess = "ClearValueSearch",
                        }))
    {
        <label>Tiêu đề :</label> 
        @Html.TextBox("keySearch", null,
                    new
                    {
                        style = "width:350px;",
                        data_autocomplete = @Url.Action("GetArticleName", "Article", new { articleID = "0" }),
                        multiple_line = "one"
                    })
    <input type="submit" value="Search" style="margin: 0 0 0 0; padding: 3px 3px 3px 3px;" />
    }

   
    
    @using (Ajax.BeginForm("AdvanceSearch2", "Article",
                            new AjaxOptions
                            {
                                UpdateTargetId = "searchResultDisplay",
                                HttpMethod = "GET",
                                InsertionMode = InsertionMode.Replace,
                                LoadingElementId = "progress_related",
                                LoadingElementDuration = 2000
                            }, new { style = "margin: -35px 0 0 510px;" }))
    {
    
    <label>Chủ đề(kỳ) :</label> 
    @Html.TextBox("artSubjectName", null,
                            new
                            {
                                style = "width:330px;",
                                maxlength = "250",
                                data_autocomplete = @Url.Action("GetSubject", "ArticleSubject"),
                                targetid = "subjectID",
                                multiple_line = "one"
                            })
                
    @Html.Hidden("subjectID")
    <input type="submit" value="Search" style="margin: 10px 0 0 0; padding: 3px 3px 3px 3px" />
    }
           
    <br />
    <div id="tab1_content" class="tab_content">
          <div id="searchResultDisplay">
                <table width="100%">
                    <tr>
                        <td>
                            <div id="tablewrapper">
                                <div id="tableheader">
                                    <div class="search">
                                        <select id="columns" onchange="sorter.search('query')">
                                        </select>
                                        <input type="text" id="query" onkeyup="sorter.search('query')" style="width:170px;" />
                                    </div>
                                    <div class="details">
                                        <div class="ddl">
                                             
                                             <div><label>Trạng thái :</label>
                                             @using (Html.BeginForm("ChangeArticleStatus", "Article", FormMethod.Post, new { id = "TheForm1" }))
                                             {
                                                @Html.DropDownList("articleStatusID", (SelectList)ViewBag.ArticleStatusList, "Tất cả", new { onchange = "this.form.submit();" })
                                             }
                                             </div>

                                            <div><label>Loại :</label>
                                             @using (Html.BeginForm("ChangeArticleType", "Article", FormMethod.Post, new { id = "TheForm2" }))
                                             {
                                                @*@Html.DropDownList("articleTypeID", (SelectList)ViewBag.ArticleTypeList, "Tất cả", new { onchange = "this.form.submit();" })*@
                                                 Html.RenderAction("BuildArticleType_DropdownList", "Article", new { id = "articleTypeID" });
                                             }
                                             </div>

                                             <div><label>Mới nhất :</label>
                                             @using (Html.BeginForm("ChangeAmountToShow", "Article", FormMethod.Post, new { id = "TheForm3" }))
                                             { 
                                                @Html.DropDownList("amount", (SelectList)ViewBag.amountList, "tất cả", new { onchange = "this.form.submit();" })
                                             }
                                             </div>
                                        </div>
                                        <div>
                                            Kết quả
                                            <span id="startrecord"></span>-<span id="endrecord"></span>
                                            của
                                            <span id="totalrecords"></span>
                                        </div>
                                        <div><a href="javascript:sorter.reset()">Thiết lập lại</a></div>
                                    </div>
                                </div>
                                <table cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable">
                                    <thead>
                                        <tr>
                                            <th><h3>Mã số</h3></th>
                                            <th class="nosort"><h3>Ảnh</h3></th>
                                            <th><h3>Tiêu đề</h3></th>
                                            <th><h3>View</h3></th>
                                            <th><h3>Thành viên</h3></th>
                                            <th><h3>Quản lý</h3></th>
                                            <th><h3>Lần sửa cuối</h3></th>
                                            <th><h3>Ẩn/Hiện</h3></th>
                                            <th class="nosort"><h3>Xem nhanh</h3></th>
                                            <th class="nosort"><h3>Sửa</h3></th>
                                            <th class="nosort"><h3>Xóa</h3></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        
                                        @foreach (var item in Model)
                                        { 
                                        <tr>
                                            <td style="width: 50px; text-align: center;">
                                                @item.ArticleID
                                            </td>
                                            <td style="text-align: center;">
                                                 <img src="../../../Content/images/article/thumbnail/@item.Photo" alt="@item.Photo"  class="img70x70"/>
                                            </td>
                                            <td style="text-align: center;">
                                                @item.Title 
                                            </td>
                                            <td style="width: 40px; text-align: center;">
                                                @item.ViewNumber
                                            </td>
                                            <td style="width: 90px; text-align: center;">
                                                @item.MemberName
                                            </td>
                                            <td style="text-align: center;">
                                                @item.AdminName
                                            </td>
                                            <td style="width: 90px; text-align: center;">
                                                @String.Format(vngoodlife.Util.ConstantClass._dateTimeFormat, item.UpdateDate)
                                            </td>
                                            <td style="width:50px;text-align: center">
                                                @if (item.ArticleVisible && (item.ArtStatusID == 3 || item.ArtStatusID == 4))
                                                {
                                                    <text> </text>
                                                    <span style="color:Green;font-weight:bolder">hiện</span>
                                                }
                                                else
                                                {
                                                    <text></text>
                                                    <span style="color:Red;font-weight:bolder">ẩn</span>
                                                }
                                            </td>
                                            <td style="width:70px; text-align: center;">
                                                  @if (item.ArticleVisible && item.ArtStatusID != 1 && item.ArtStatusID != 2)
                                                  {
                                                 <a href="@Url.RouteUrl("ArticleDetailFrontend", new { articleSeoUrl = item.ArticleSeoUrl })" target="_blank">
                                                    <img src="../../../Content/table/images/grid_preview.png" alt="Xem nhanh" title="Xem nhanh"/></a>
                                                  } 
                                            </td>
                                            
                                            <td style="width:50px;text-align: center">
                                               <a href="@Url.Action("ArticleEdit", "Article", new { articleID = item.ArticleID })">
                                               <img src="../../../Content/table/images/grid_edit.png" alt="Chỉnh sửa" title="Chỉnh sửa bài viết"/></a>
                                            </td>
                                            <td style="width:50px;text-align: center">
                                                @using (Html.BeginForm("DeleteArticle", "Article", FormMethod.Post))
                                                {
                                                    @Html.AntiForgeryToken(vngoodlife.Util.AntiKey.EditSalt)
                                                    @Html.Hidden("articleID", item.ArticleID)

                                                    <input class="SubmitDelete" type="submit" value="" onclick="javascript: if (confirm('Bạn muốn xóa bài viết này tin này?')) { window.location.href='#' } else { return false; };"/>
                                                }
                                            </td>
                                        </tr>
                                         }
                                    </tbody>
                                </table>
                                <div id="tablefooter">
                                    <div id="tablenav">
                                        <div>
                                            <img alt="" src="../../../Content/table/images/first.gif" />
                                            <img src="../../../Content/table/images/first.gif" width="16" height="16" alt="First Page"
                                                onclick="sorter.move(-1,true)" />
                                            <img src="../../../Content/table/images/previous.gif" width="16" height="16" alt="First Page"
                                                onclick="sorter.move(-1)" />
                                            <img src="../../../Content/table/images/next.gif" width="16" height="16" alt="First Page" onclick="sorter.move(1)" />
                                            <img src="../../../Content/table/images/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
                                        </div>
                                        <div>
                                            <select id="pagedropdown"></select>
                                        </div>
                                        <div>
                                            <a href="javascript:sorter.showall()">Xem tất cả</a>
                                        </div>
                                    </div>
                                    <div id="tablelocation">
                                        <div>
                                            <select onchange="sorter.size(this.value)">
                                                <option value="25" selected="selected">25</option>
                                                <option value="50">50</option>
                                                <option value="100">100</option>
                                            </select>
                                            <span>Kết quả mỗi trang</span>
                                        </div>
                                        <div class="page">
                                            Trang
                                            <span id="currentpage"></span>
                                            của
                                            <span id="totalpages"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <script type="text/javascript" src="../../../Content/table/0.js"></script>
                            <script type="text/javascript">
                                var sorter = new TINY.table.sorter('sorter', 'table', {
                                    headclass: 'head',
                                    ascclass: 'asc',
                                    descclass: 'desc',
                                    evenclass: 'evenrow',
                                    oddclass: 'oddrow',
                                    evenselclass: 'evenselected',
                                    oddselclass: 'oddselected',
                                    paginate: true,
                                    size: 25,
                                    colddid: 'columns',
                                    currentid: 'currentpage',
                                    totalid: 'totalpages',
                                    startingrecid: 'startrecord',
                                    endingrecid: 'endrecord',
                                    totalrecid: 'totalrecords',
                                    hoverid: 'selectedrow',
                                    pageddid: 'pagedropdown',
                                    navid: 'tablenav',
                                    /*
                                    sortcolumn: 0,
                                    sortdir: -1,
                                    sum:[8],
                                    avg:[6,7,8,9],
                                    columns:[{index:7, format:'%', decimals:1},{index:8, format:'$', decimals:0}], */
                                    init: true
                                });
                            </script>
                        </td>
                    </tr>
                </table>
                </div>
            </div>
        </div>
   </div>
<script type="text/javascript">
    function ClearValueSearch() {
        $("#searchArticleID").val("");
    }

</script>